package com.tencreat.service.mall.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.mall.MallSignIn;
import com.tencreat.mapper.mall.MallSignInMapper;
import com.tencreat.service.mall.IMallSignInService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 签到配置Service业务层处理
 *
 * @author tencreat
 * @date 2022-01-17
 */
@Service
public class MallSignInServiceImpl extends ServiceImpl<MallSignInMapper, MallSignIn> implements IMallSignInService {


    /**
     * 查询签到配置
     *
     * @param id 签到配置ID
     * @return 签到配置
     */
    @Override
    public MallSignIn selectMallSignInById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询签到配置列表
     *
     * @param mallSignIn 签到配置
     * @return 签到配置
     */
    @Override
    public List<MallSignIn> selectMallSignInList(MallSignIn mallSignIn) {
        return baseMapper.selectList(Wrappers.query(mallSignIn));
    }

    /**
     * 新增签到配置
     *
     * @param mallSignIn 签到配置
     * @return 结果
     */
    @Override
    public int insertMallSignIn(MallSignIn mallSignIn) {
        mallSignIn.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallSignIn);
    }

    /**
     * 修改签到配置
     *
     * @param mallSignIn 签到配置
     * @return 结果
     */
    @Override
    public int updateMallSignIn(MallSignIn mallSignIn) {
        mallSignIn.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallSignIn);
    }

    /**
     * 批量删除签到配置
     *
     * @param ids 需要删除的签到配置ID
     * @return 结果
     */
    @Override
    public int deleteMallSignInByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除签到配置信息
     *
     * @param id 签到配置ID
     * @return 结果
     */
    @Override
    public int deleteMallSignInById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
